﻿using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using 纺织贸易管理系统;

namespace BLL
{
   public static class 原料盘盈BLL
    {
        public static void 保存单据(DanjuTable danju,List<ImportAndExportOfRawMaterials> raws)
        {
            Connect.dbcontext.Insertable(danju).ExecuteCommand();
            Connect.dbcontext.Insertable<ImportAndExportOfRawMaterials>(raws).ExecuteCommand();
            库存BLL.原料入库(raws);
        }
        public static void 删除单据(string danhao)
        {
            var danju = Connect.dbcontext.Queryable<DanjuTable>().First(x => x.dh == danhao);
            var raws = Connect.dbcontext.Queryable<ImportAndExportOfRawMaterials>().Where(x => x.DocNum == danhao).ToList();
            Connect.dbcontext.Deleteable(danju).ExecuteCommand();
            Connect.dbcontext.Deleteable(raws).ExecuteCommand();
            库存BLL.原料出库(raws);
        }
        public static void 修改单据(DanjuTable danju, List<ImportAndExportOfRawMaterials> raws)
        {
            删除单据(danju.dh);
            保存单据(danju, raws);
        }
    }
}
